package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os/exec"
)

func DialCount() int64 {
	cmd := exec.Command("/bin/bash", "-c", "ls|wc -l")
	out, _ := cmd.StdoutPipe()
	if err := cmd.Start(); err != nil {
		log.Fatal(err)
	}
	bytes, err := ioutil.ReadAll(out)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(bytes))
	return int64(bytes[-1])
}

func OutgoingCount() int64 {
	cmd := exec.Command("/usr/sbin/rasterisk", "-g -C /etc/asterisk/gateway/asterisk.conf -x 'core show channels verbose'|awk '{print $7}' |grep '^SIP' |wc -l")
	out, _ := cmd.StdoutPipe()
	if err := cmd.Start(); err != nil {
		log.Fatal(err)
	}
	bytes, _ := ioutil.ReadAll(out)
	return int64(bytes[0])
}

func main() {
	fmt.Println(DialCount())
}
